-- 
-- Nuevo collation para los casos de manejo de codigos en sentencias between, order by y > < 
--
select abaco_utiles.aaVistasDropear();

CREATE OR REPLACE FUNCTION public.modificar_collates(
	)
    RETURNS boolean
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE 
AS $BODY$
DECLARE
BEGIN
  EXECUTE 'ALTER TABLE CTB ALTER COLUMN COD TYPE character varying(20) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  EXECUTE 'ALTER TABLE CTBR ALTER COLUMN COD TYPE character varying(20) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  
  EXECUTE 'ALTER TABLE ART  ALTER COLUMN COD TYPE character varying(30) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  EXECUTE 'ALTER TABLE ARTR ALTER COLUMN COD TYPE character varying(50) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  
  EXECUTE 'ALTER TABLE PAD  ALTER COLUMN COD TYPE character varying(14) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  EXECUTE 'ALTER TABLE PADR ALTER COLUMN COD TYPE character varying(20) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  
  EXECUTE 'ALTER TABLE CONCEP ALTER COLUMN COD TYPE character varying(12) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  EXECUTE 'ALTER TABLE CONR   ALTER COLUMN COD TYPE character varying(20) COLLATE pg_catalog.' || chr(34) || 'C' || chr(34) || ';';
  
  RETURN TRUE;
  
END;
$BODY$;

ALTER FUNCTION public.modificar_collates()
    OWNER TO abacouser;

SELECT public.modificar_collates();

DROP FUNCTION public.modificar_collates();

select abaco_utiles.aaVistasRestaurar();

select aaVersion('486.00','485.00');

